import hashlib

def backup_model(model, backup_path):
    """
    备份模型
    :param model: 模型参数
    :param backup_path: 备份路径
    :return: 备份成功
    """
    model_hash = hashlib.sha256(model).hexdigest()
    with open(backup_path, "wb") as f:
        f.write(model)
    return model_hash

# 示例
model = b"model_weights"
backup_path = "backup_model.bin"
model_hash = backup_model(model, backup_path)
print(f"Model backed up with hash: {model_hash}")